package threadUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class MainStart {

    public static void main(String[] args) {

        CountDownLatch countDownLatch = new CountDownLatch(3);

        List<BaseCountDown> list = new ArrayList<>();
        list.add(new Test1(countDownLatch));
        list.add(new Test2(countDownLatch));
        list.add(new Test3(countDownLatch));

        Executor executor = Executors.newFixedThreadPool(list.size());

        list.forEach(executor::execute);

        try {
            countDownLatch.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        list.forEach(item -> {
            System.out.println("成功情况：" + item.isSuccess());
        });
    }

}
